package com.controller;

import com.model.Surat;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

public class DaftarTableModelSurat extends AbstractTableModel{

    String columNames[] = {"NO_SURAT", "PERIHAL", "ASAL_SURAT", "PENERIMA_SURAT", "RUANG", "LEMARI", "LOKER", "PETUGAS_PENERIMA", "TGL_MASUK", "TIPE_FILE","STATUS"};
    public ArrayList<Surat> data;

    public DaftarTableModelSurat() {
    }
    public DaftarTableModelSurat(ArrayList<Surat> data) {
        this.data = data;
    }

    @Override
    public int getRowCount() {
        return getData().size();
    }
    @Override
    public int getColumnCount() {
        return columNames.length;
    }

    @Override
    public String getColumnName(int col) {
        return columNames[col];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Surat temp = getData().get(rowIndex);
        if (columnIndex == 0) {
            return temp.getNomorSurat();
        } else if (columnIndex == 1) {
            return temp.getPerihal();
        } else if (columnIndex == 2) {
            return temp.getAsalSurat();
        } else if (columnIndex == 3) {
            return temp.getPenerimaSurat();
        } else if (columnIndex == 4) {
            return temp.getLetakRuang();
        } else if (columnIndex == 5){
            return temp.getLetakLemari();
        } else if (columnIndex == 6){
            return temp.getLetakLoker();
        } else if (columnIndex == 7){
            return temp.getNamaPenerima();
        } else if (columnIndex == 8){
            return temp.getanggalMasuk();
        } else if (columnIndex == 9){
            return temp.getFilescan();
        } else {
            return temp.getStatus();
        }
    }
    public ArrayList<Surat> getData() {
        return data;
    }
    public void setData(ArrayList<Surat> data) {
        this.data = data;
    }
}
